package no.group.gowther.rest.vo;

import no.group.gowther.service.dto.*;
import no.group.gowther.util.ImageUtils;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author ayatsuji
 * @date 2022-04-11 22:49
 * @since
 */
public class FilingDetailVO {
    private boolean dir;
    private List<String> imageCodes;
    private boolean hasNext;
    private String sessionId;
    private ImageUtils.Dimension dimension;

    private String filePath;

    private Long onePieceId;
    private String name;
    private List<TagDTO> tag;

    public FilingDetailVO(FilingDetailDTO filingDetailDTO) {
        this.dir = filingDetailDTO.isDir();
        this.imageCodes = filingDetailDTO.getImageCodes().stream().map(ImageCode::getUrlEncodeImageCode).collect(Collectors.toList());
        this.hasNext = filingDetailDTO.isHasNext();
        this.sessionId = filingDetailDTO.getSessionId();
        this.dimension = filingDetailDTO.getDimension();

        if (filingDetailDTO instanceof FileFilingDetailDTO fileFilingDetailDTO) {
            this.filePath = fileFilingDetailDTO.getFilePath();
        }

        if (filingDetailDTO instanceof OnePieceFilingDetailDTO onePieceFilingDetailDTO) {
            this.onePieceId = onePieceFilingDetailDTO.getOnePieceId();
            this.name = onePieceFilingDetailDTO.getName();
            this.tag = onePieceFilingDetailDTO.getTag();
        }
    }

    public boolean isDir() {
        return dir;
    }

    public void setDir(boolean dir) {
        this.dir = dir;
    }

    public List<String> getImageCodes() {
        return imageCodes;
    }

    public void setImageCodes(List<String> imageCodes) {
        this.imageCodes = imageCodes;
    }

    public boolean isHasNext() {
        return hasNext;
    }

    public void setHasNext(boolean hasNext) {
        this.hasNext = hasNext;
    }

    public String getSessionId() {
        return sessionId;
    }

    public void setSessionId(String sessionId) {
        this.sessionId = sessionId;
    }

    public ImageUtils.Dimension getDimension() {
        return dimension;
    }

    public void setDimension(ImageUtils.Dimension dimension) {
        this.dimension = dimension;
    }

    public String getFilePath() {
        return filePath;
    }

    public void setFilePath(String filePath) {
        this.filePath = filePath;
    }

    public Long getOnePieceId() {
        return onePieceId;
    }

    public void setOnePieceId(Long onePieceId) {
        this.onePieceId = onePieceId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<TagDTO> getTag() {
        return tag;
    }

    public void setTag(List<TagDTO> tag) {
        this.tag = tag;
    }
}
